home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdemacros.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-09-09  |  7.7 KB  |  222 lines

  1. /* kdecore/kdemacros.h.  Generated from kdemacros.h.in by configure.  */
  2. /* This file is part of the KDE libraries
  3.     Copyright (c) 2002-2003 KDE Team
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef _KDE_MACROS_H_
  22. #define _KDE_MACROS_H_
  23.  
  24. /* Set by configure */
  25. /* #undef __KDE_HAVE_GCC_VISIBILITY */
  26.  
  27. /**
  28.  * The KDE_NO_EXPORT macro marks the symbol of the given variable 
  29.  * to be hidden. A hidden symbol is stripped during the linking step, 
  30.  * so it can't be used from outside the resulting library, which is similar
  31.  * to static. However, static limits the visibility to the current 
  32.  * compilation unit. hidden symbols can still be used in multiple compilation
  33.  * units.
  34.  *
  35.  * \code
  36.  * int KDE_NO_EXPORT foo;
  37.  * int KDE_EXPORT bar;
  38.  * \end
  39.  */
  40.  
  41. #ifdef __KDE_HAVE_GCC_VISIBILITY
  42. #define KDE_NO_EXPORT __attribute__ ((visibility("hidden")))
  43. #define KDE_EXPORT __attribute__ ((visibility("default")))
  44. #elif defined(Q_WS_WIN)
  45. #define KDE_NO_EXPORT
  46. #define KDE_EXPORT __declspec(dllexport)
  47. #else
  48. #define KDE_NO_EXPORT
  49. #define KDE_EXPORT
  50. #endif
  51.  
  52. /**
  53.  * KDE_Q_EXPORT_PLUGIN is a workaround for Qt not being able to
  54.  * cope with symbol visibility.
  55.  */
  56. #define KDE_Q_EXPORT_PLUGIN(PLUGIN) \
  57.   Q_EXTERN_C KDE_EXPORT const char* qt_ucm_query_verification_data(); \
  58.   Q_EXTERN_C KDE_EXPORT QUnknownInterface* ucm_instantiate(); \
  59.   Q_EXPORT_PLUGIN(PLUGIN)
  60.  
  61. /**
  62.  * The KDE_PACKED can be used to hint the compiler that a particular
  63.  * structure or class should not contain unnecessary paddings. 
  64.  */
  65.  
  66. #ifdef __GNUC__
  67. #define KDE_PACKED __attribute__((__packed__))
  68. #else
  69. #define KDE_PACKED
  70. #endif
  71.  
  72. /**
  73.  * The KDE_DEPRECATED macro can be used to trigger compile-time warnings
  74.  * with newer compilers when deprecated functions are used.
  75.  *
  76.  * For non-inline functions, the macro gets inserted at the very end of the
  77.  * function declaration, right before the semicolon:
  78.  *
  79.  * \code
  80.  * DeprecatedConstructor() KDE_DEPRECATED;
  81.  * void deprecatedFunctionA() KDE_DEPRECATED;
  82.  * int deprecatedFunctionB() const KDE_DEPRECATED;
  83.  * \endcode
  84.  *
  85.  * Functions which are implemented inline are handled differently: for them,
  86.  * the KDE_DEPRECATED macro is inserted at the front, right before the return
  87.  * type, but after "static" or "virtual":
  88.  *
  89.  * \code
  90.  * KDE_DEPRECATED void deprecatedInlineFunctionA() { .. }
  91.  * virtual KDE_DEPRECATED int deprecatedInlineFunctionB() { .. }
  92.  * static KDE_DEPRECATED bool deprecatedInlineFunctionC() { .. }
  93.  * \end
  94.  *
  95.  * You can also mark whole structs or classes as deprecated, by inserting the
  96.  * KDE_DEPRECATED macro after the struct/class keyword, but before the
  97.  * name of the struct/class:
  98.  *
  99.  * \code
  100.  * class KDE_DEPRECATED DeprecatedClass { };
  101.  * struct KDE_DEPRECATED DeprecatedStruct { };
  102.  * \endcode
  103.  *
  104.  * \note
  105.  * It does not make much sense to use the KDE_DEPRECATED keyword for a Qt signal;
  106.  * this is because usually get called by the class which they belong to,
  107.  * and one'd assume that a class author doesn't use deprecated methods of his
  108.  * own class. The only exception to this are signals which are connected to
  109.  * other signals; they get invoked from moc-generated code. In any case, 
  110.  * printing a warning message in either case is not useful.
  111.  * For slots, it can make sense (since slots can be invoked directly) but be
  112.  * aware that if the slots get triggered by a signal, the will get called from
  113.  * moc code as well and thus the warnings are useless.
  114.  *
  115.  * \par
  116.  * Also note that it is not possible to use KDE_DEPRECATED for classes which
  117.  * use the k_dcop keyword (to indicate a DCOP interface declaration); this is
  118.  * because the dcopidl program would choke on the unexpected declaration
  119.  * syntax.
  120.  */
  121.  
  122. #ifndef KDE_DEPRECATED
  123. #if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)
  124.   /* gcc >= 3.2 */
  125. # define KDE_DEPRECATED __attribute__ ((deprecated))
  126. #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
  127.   /* msvc >= 7 */
  128. # define KDE_DEPRECATED __declspec(deprecated)
  129. #else
  130. # define KDE_DEPRECATED
  131. #endif
  132. #endif
  133.  
  134. /**
  135.  * The KDE_ISLIKELY macro tags a boolean expression as likely to evaluate to
  136.  * 'true'. When used in an if ( ) statement, it gives a hint to the compiler
  137.  * that the following codeblock is likely to get executed. Providing this
  138.  * information helps the compiler to optimize the code for better performance.
  139.  * Using the macro has an insignificant code size or runtime memory footprint impact.
  140.  * The code semantics is not affected.
  141.  *
  142.  * \note
  143.  * Providing wrong information ( like marking a condition that almost never
  144.  * passes as 'likely' ) will cause a significant runtime slowdown. Therefore only
  145.  * use it for cases where you can be sure about the odds of the expression to pass
  146.  * in all cases ( independent from e.g. user configuration ).
  147.  *
  148.  * \par
  149.  * The KDE_ISUNLIKELY macro tags an expression as unlikely evaluating to 'true'. 
  150.  *
  151.  * \note
  152.  * Do NOT use ( !KDE_ISLIKELY(foo) ) as an replacement for KDE_ISUNLIKELY !
  153.  *
  154.  * \code
  155.  * if ( KDE_ISUNLIKELY( testsomething() ) )
  156.  *     abort();     // assume its unlikely that the application aborts
  157.  * \endcode
  158.  */
  159. #if __GNUC__ - 0 >= 3
  160. # define KDE_ISLIKELY( x )    __builtin_expect(!!(x),1)
  161. # define KDE_ISUNLIKELY( x )  __builtin_expect(!!(x),0)
  162. #else
  163. # define KDE_ISLIKELY( x )   ( x )
  164. # define KDE_ISUNLIKELY( x )  ( x )
  165. #endif
  166.  
  167. /**
  168.  * This macro, and it's friends going up to 10 reserve a fixed number of virtual
  169.  * functions in a class.  Because adding virtual functions to a class changes the
  170.  * size of the vtable, adding virtual functions to a class breaks binary
  171.  * compatibility.  However, by using this macro, and decrementing it as new
  172.  * virtual methods are added, binary compatibility can still be preserved.
  173.  *
  174.  * \note The added functions must be added to the header at the same location
  175.  * as the macro; changing the order of virtual functions in a header is also
  176.  * binary incompatible as it breaks the layout of the vtable.
  177.  */
  178.  
  179. #define RESERVE_VIRTUAL_1 \
  180.     virtual void reservedVirtual1() {}
  181. #define RESERVE_VIRTUAL_2 \
  182.     virtual void reservedVirtual2() {} \
  183.     RESERVE_VIRTUAL_1
  184. #define RESERVE_VIRTUAL_3 \
  185.     virtual void reservedVirtual3() {} \
  186.     RESERVE_VIRTUAL_2
  187. #define RESERVE_VIRTUAL_4 \
  188.     virtual void reservedVirtual4() {} \
  189.     RESERVE_VIRTUAL_3
  190. #define RESERVE_VIRTUAL_5 \
  191.     virtual void reservedVirtual5() {} \
  192.     RESERVE_VIRTUAL_4
  193. #define RESERVE_VIRTUAL_6 \
  194.     virtual void reservedVirtual6() {} \
  195.     RESERVE_VIRTUAL_5
  196. #define RESERVE_VIRTUAL_7 \
  197.     virtual void reservedVirtual7() {} \
  198.     RESERVE_VIRTUAL_6
  199. #define RESERVE_VIRTUAL_8 \
  200.     virtual void reservedVirtual8() {} \
  201.     RESERVE_VIRTUAL_7
  202. #define RESERVE_VIRTUAL_9 \
  203.     virtual void reservedVirtual9() {} \
  204.     RESERVE_VIRTUAL_8
  205. #define RESERVE_VIRTUAL_10 \
  206.     virtual void reservedVirtual10() {} \
  207.     RESERVE_VIRTUAL_9
  208.  
  209. /**
  210.  * The KDE_WEAK_SYMBOL macro can be used to tell the compiler that
  211.  * a particular function should be a weak symbol (that e.g. may be overriden
  212.  * in another library, -Bdirect will not bind this symbol directly)
  213.  */
  214.  
  215. #ifdef __GNUC__
  216. #define KDE_WEAK_SYMBOL __attribute__((__weak__))
  217. #else
  218. #define KDE_WEAK_SYMBOL
  219. #endif
  220.  
  221. #endif /* _KDE_MACROS_H_ */
  222.